<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: zoud
  Date: 28/09/2016
  Time: 17:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Database Commons - Admin home</title>
</head>
<body>
<h2 class="ui header">Welcome, ${currentUser.lastName} ${currentUser.firstName}</h2>
<div class="sub header">Manage your database system</div>

<div class="ui segment">
    <h3>Profiles</h3>
    <p>Email: ${currentUser.email}</p>
    <p>Role: ${currentUser.roleList[0].name}</p>
    <a class="ui blue labeled icon button" href="${host}/user/profiles">
        Update profiles
        <i class="user icon"></i>
    </a>
    <a class="ui red labeled icon button" href="${host}/user/password">
        Reset password
        <i class="lock icon"></i>
    </a>
    <a class="ui green labeled icon button" href="${host}/curator/home">Curate database <i class="icon edit"></i></a>
</div>

<div class="ui segment">
    <h3>Create User</h3>
    <div class="ui grid">
        <div class="five wide column">
            <form class="ui form" action="${host}/admin/user/create" method="post" id="createUser">
                <div class="field required">
                    <label>Email: </label>
                    <input type="text" name="email" required/>
                </div>
                <div class="two fields">
                    <div class="field required">
                        <label>Password: </label>
                        <input type="password" name="password"/>
                    </div>
                    <div class="field required">
                        <label>Confirm Password: </label>
                        <input type="password" name="repwd"/>
                    </div>
                </div>
                <div class="two fields">
                    <div class="field required">
                        <label>First name: </label>
                        <input type="text" name="firstName"/>
                    </div>
                    <div class="field required">
                        <label>Last name: </label>
                        <input type="text" name="lastName"/>
                    </div>
                </div>
                <div class="ui primary submit button">Submit</div>
                <div class="ui error message"></div>
            </form>
        </div>
    </div>
    <script>
        $(document).ready(function () {
            console.log("validate");
            $('#createUser').form(
                {
                    inline: true,
                    on: 'blur',
                    fields: {
                        email: ['empty', 'email'],
                        firstName: 'empty',
                        lastName: 'empty',
                        password: ['empty', 'minLength[6]'],
                        repwd: 'match[password]'
                    }
                }
            );
        });
    </script>
</div>
</body>
</html>
